/**
 * @file    pc_data_link.h
 * @brief   通信协议数据链路
 * @author  liuwei
 * @version 1.0.1
 * @date    2023-04-25
 * 
 * @copyright Copyright (c) 2023 JBD-Energy Storage Technology Co. LTD
 * 
 * @par 修改日志:
 * <table>
 * <tr><th>Date       <th>Version   <th>Author   <th>Description
 * <tr><td>2023-04-25 <td>1.0.1     <td>Liuwei   <td>首次创建
 * </table>
 */

#ifndef __PC_DATA_LINK_H_
#define __PC_DATA_LINK_H_

/* file includes -------------------------------------------------------------*/
#include "mcu_type.h"

/* cplusplus -----------------------------------------------------------------*/
#ifdef __cplusplus
extern "C" {
#endif

/* macro/define/typedef ------------------------------------------------------*/
#define PARALLEL_SALVE_MAX     (16)
/** 基本数据信息 */
#pragma pack(1)
typedef struct 
{
    uint16_t batt_volt; 
    uint16_t pack_volt; 
    uint32_t bus_curr;
    uint16_t soc;
    uint32_t real_cap;
    uint32_t full_cap;
    uint32_t std_cap;
    uint16_t mos_temp;
    uint16_t pcb_temp;
    uint16_t envir_temp;
    uint8_t curr_state;
    uint8_t soh;
    uint32_t prp_msg;
    uint32_t alm_msg;
    uint16_t sign_msg;
    uint16_t cycle;
    uint8_t maxc_sn;
    uint16_t maxc_volt;
    uint8_t minc_sn;
    uint16_t minc_volt;
    uint16_t age_volt;
    uint8_t maxt_sn;
    uint16_t maxt_temp;
    uint8_t mint_sn;
    uint16_t mint_temp;
}base_data_type;

typedef struct 
{
    uint16_t alm_val;
    uint16_t alm_rcv;
    uint16_t alm_dly;
    uint16_t prp_val;
    uint16_t prp_rcv;
    uint16_t prp_dly;
}prp_param_type;

typedef struct 
{
    uint16_t alm_val;
    uint16_t alm_rcv;
    uint16_t alm_dly;
    uint16_t prp_val; 
    uint16_t prp_dly;
    uint16_t prp_rcv_dly;
    uint16_t lock_times;
	uint16_t prp2_val;
	uint16_t prp2_dly;
    uint16_t prp2_rcv_dly;
    uint16_t prp2_lock_times;
}curr_param_type;
typedef struct 
{
    prp_param_type cov;
    prp_param_type cuv;
    prp_param_type bov;
    prp_param_type buv; 
    curr_param_type occ;
    curr_param_type ocd;
    prp_param_type otc;
    prp_param_type utc;
    prp_param_type otd;
    prp_param_type utd;
    prp_param_type otm;
    prp_param_type ote;
    prp_param_type tdiff;
    prp_param_type vdiff;
    prp_param_type socl;
	prp_param_type ute;
}prp_prarm_list_type;

typedef struct
{
    uint32_t std_cap;
    uint32_t full_cap;
    uint32_t real_cap;
    uint16_t soc;
    uint16_t soh;
    uint16_t damp_factor;
    uint16_t cycle;
    uint8_t batt_type;
    uint8_t manufacturer;
    uint16_t blc_op_volt;
    uint16_t blc_op_vdiff;
    uint16_t hot_start_temp;
    uint16_t hot_stop_temp;
    uint16_t batt_self_pow;
    uint16_t full_chg_volt;
    uint16_t full_chg_curr;
    uint32_t total_chg_ah;
    uint32_t total_dsg_ah;
    uint16_t ocv1_volt;
    uint16_t ocv1_soc;
    uint16_t ocv2_volt;
    uint16_t ocv2_soc;
    uint16_t ocv3_volt;
    uint16_t ocv3_soc;
    uint16_t ocv4_volt;
    uint16_t ocv4_soc;
}batt_param_type;

typedef struct
{
    uint8_t bms_code[30];
    uint8_t bms_year;
    uint8_t bms_month;
    uint8_t bms_date;
    uint8_t sn_code[30];
    uint8_t pack_year;
    uint8_t pack_month;
    uint8_t pack_date;
    uint8_t mft_code[30];
    uint8_t ptl_type;
}param_pack_type;

typedef struct 
{
    uint8_t hard_type[15];
    uint8_t ver_hard;
    uint8_t ver_main;
    uint8_t ver_release;
    uint8_t ver_test;
    uint8_t ver_boot;
    uint8_t ver_ptl;
}ver_msg_type;

typedef struct 
{
    uint8_t addr;
    uint16_t batt_volt;
    uint16_t bus_curr;
    uint16_t soc;
    uint8_t curr_state;
    uint8_t mos_state;
    uint16_t max_volt;
    uint16_t min_volt;
    uint8_t max_temp;
    uint8_t min_temp;
    uint8_t rsd[5];
}salve_msg_type;
typedef struct 
{
    uint32_t bus_volt;
    uint32_t bus_curr;
    uint16_t soc;
    uint8_t run_state;
    uint32_t alm_state;
    uint32_t prp_state;
    uint16_t max_chg_curr;
    uint16_t max_dsg_curr;
    uint16_t max_chg_volt;
    uint16_t max_dsg_volt;
    uint32_t pack_ol_state;
    uint8_t pack_ol_num;
    uint8_t rsd[12];
    salve_msg_type salve_data_buf[PARALLEL_SALVE_MAX];
}parallel_msg_type;

typedef struct 
{
	uint16_t full_chg_volt;
	uint16_t full_chg_curr;
}other_para_type;

#pragma pack()
/* variables -----------------------------------------------------------------*/

/*******************************************************************************
 * public API List
 ******************************************************************************/

#ifdef __cplusplus
}
#endif

#endif  /* #ifndef __PC_DATA_LINK_H_ */
/********** Copyright (c) 2023 JBD-Energy Storage Technology Co. LTD *********/

